<?php

function LoadLanguage()
{
	if(isset($_GET['lang']))
	{
		$lang = SetLanguage($_GET['lang']);
		if($lang !== false) return $lang;
	}
	if(isset($_COOKIE['lang']))
	{
		$lang = $_COOKIE['lang'];
		if($lang == 'fr' || $lang == 'en')
			return $lang;
	}
	return 'fr';
}

function SetLanguage($lang)
{
	if($lang != 'fr' && $lang != 'en') return false;
	setcookie('lang', $lang, time() + 3600*24*365);
	header('Location: ' . $_GET['next']);
	exit;
	return $lang;
}

function MakeLangPath()
{
	global $lang;
	global $mcrp;
	return $mcrp . 'lang/' . $lang['lang'] . '/l_';
}

?>